超強 過濾HTML代碼的函數包括過濾CSS和JS
作者:tank 日期:2006-10-23
'過濾HTML代碼的函數包括過濾CSS和JS
Function RemoveHTML(strHTML)
StrHtml = Replace(StrHtml,vbCrLf,"")
StrHtml = Replace(StrHtml,Chr(13)&Chr(10),"")
StrHtml = Replace(StrHtml,Chr(13),"")
StrHtml = Replace(StrHtml,Chr(10),"")
StrHtml = Replace(StrHtml," ","")
StrHtml = Replace(StrHtml," ","")
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'取閉合的<>
objRegExp.Pattern = ""
'進行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,並替換掉匹配的項目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
'取閉合的<>
objRegExp.Pattern = ""
'進行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,並替換掉匹配的項目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
'取閉合的<>
objRegExp.Pattern = "<.+?>"
'進行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,並替換掉匹配的項目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
檢測字串出現的次數
Function CheckTheChar(TheChar,TheString)
'TheChar="要檢測的字串"
'TheString="待檢測的字串"
if inStr(TheString,TheChar) then
for n =1 to Len(TheString)
if Mid(TheString,n,Len(TheChar))=TheChar then
CheckTheChar=CheckTheChar+1
End if
Next
CheckTheChar="這個字元"&CheckTheChar&"次"
else
CheckTheChar="0次"
end if
End Function
<%
'函數功能:把文章內容中涉及到的圖片自動保存到本地伺服器。(注意:請先在目錄下建立tempfile目錄,用來保存臨時圖片)
'作者:小灰
'QQ:103895
'主頁:http://asp2004.net
'2004.9.13
'轉載或使用請不要刪除上面這些訊息。謝謝!
const savepath="tempfile/"
function myreplace(str)
newstr=str
set objregEx = new RegExp
objregEx.IgnoreCase = tru